<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="StyleSheet" href="../css/jpetstore.css" type="text/css" media="screen"/>
</head>
<body>
<div th:replace="common/top">

</div>
<div id="Content">
    <div id="Catalog">

        <div id="Cart">
            <div id="BackLink">
                <a href="/catalog/view">Return to Main Menu</a>
            </div>

            <h2>Shopping Cart</h2>

            <form action="/cart/updateCartQuantities" method="post">
                <table>
                    <tr>
                        <th><b>Item ID</b></th>
                        <th><b>Product ID</b></th>
                        <th><b>Description</b></th>
                        <th><b>In Stock?</b></th>
                        <th><b>Quantity</b></th>
                        <th><b>List Price</b></th>
                        <th><b>Total Cost</b></th>
                        <th>&nbsp;</th>
                    </tr>
                        <tr th:if="${cart.numberOfItems == 0}">
                            <td colspan="8"><b>Your cart is empty.</b></td>
                        </tr>
<!--                    <script src="../../../js/jquery-3.4.1.js"></script>-->
<!--                    <script src="../../../js/cartUpdate.js"></script>-->
                        <tr th:each="cartItem:${cart.cartItems}">
                            <td>
                                <a th:href="@{/catalog/viewItem?itemId=}+${cartItem.item.itemId}" th:text="${cartItem.item.itemId}">itemId</a>
                            </td>
                            <td th:text="${cartItem.item.product.productId}">
                                ${cartItem.item.product.productId}
                            </td>
                            <td th:text="${cartItem.item.attribute1}+${cartItem.item.product.name}">
                                ${cartItem.item.attribute1} ${cartItem.item.attribute2}
                                ${cartItem.item.attribute3} ${cartItem.item.attribute4}
                                ${cartItem.item.attribute5} ${cartItem.item.product.name}
                            </td>
                            <td th:text="${cartItem.inStock}">
                                ${cartItem.inStock}
                            </td>
                            <td>
                                <input type="text" th:name="${cartItem.item.itemId}"  th:value="${cartItem.quantity}"/>
                            </td>
                            <td th:text="'$'+${#numbers.formatDecimal(cartItem.item.listPrice,1,2)}"></td>
                            <td th:text="'$'+${#numbers.formatDecimal(cartItem.total,1,2)}"></td>
                            <td>
                                <a th:href="@{/cart/removeItemFromCart?workingItemId=}+${cartItem.item.itemId}" class="Button">Remove</a>
                            </td>
                        </tr>
                    <tr>
                        <td colspan="7">
                            <label th:text="'Sub Total:$'+${#numbers.formatDecimal(cart.subTotal,1,2)}"></label>
                            <input type="Button" value="Update Cart" name="updateCartQuantities"/>
                        </td>
                        <td>&nbsp;</td>
                    </tr>
                </table>
            </form>
            <a th:if="${cart.numberOfItems > 0}" class="Button" href="/cart/askCheckOut">Proceed to Checkout</a>
        </div>

        <div id="MyList" th:if="(${session.account} != null) and (${session.authenticated})">
            <div th:if="${session.account.listOption}">
                <p>Pet Favorites <br />
                    Shop for more of your favorite pets here.
                </p>
                <ul>
                    <li th:each="product:${session.myList}">
                        <a th:href="'/catalog/viewProduct?productId='+${product.productId}" th:text="${product.productId}"></a>
                    </li>
                </ul>
            </div>
        </div>

        <div id="Separator">&nbsp;</div>
    </div>
</div>

    <div th:replace="common/botton">

    </div>

</body>
</html>